import '@/plugins/axios'
import '@/plugins/element.js'

export default matchSeat;

function matchSeat() {
  // console.log("matchSeat");
  return new Promise((resolve, reject) => {
    this.axios
      .get("./api/get_seat_by_ip.php", { timeout: 1000 })
      .then((response) => {
        console.log("matchSeat", response.data);
        if (response.data.seat != "") {
          resolve(response.data.seat);
        } else {
          this.$message.warning(
            "未能通过IP地址匹配对应的席位"
          );
          // reject("未能通过IP地址匹配对应的席位");
          resolve('');
        }
      })
      .catch((error) => {
        console.log("matchSeat", error);
        this.$message.error(
          "尝试通过IP匹配席位时发生网络错误"
        );
        reject(error);
      });
  });
}